/**
 * Created by dfc on 2017/8/25.
 */
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require('copy-webpack-plugin'); //可以将单个文件或整个目录复制到构建目录中。

module.exports = {
	resolve: {
		extensions: ["*", ".scss", ".less", ".css", ".js", ".jsx"],
		modules: [
			path.join(__dirname, "..", "src"),
			"node_modules"
		],
		alias: {
			"jquery": path.join(__dirname, "..", "node_modules/jquery/dist/jquery.js"),
			"src": path.join(__dirname, "..", "src"),
			"css": path.join(__dirname, "..", "src", "style"),
			"com": path.join(__dirname, "..", "src", "components"),
			"stores": path.join(__dirname, "..", "src", "stores"),
			"view": path.join(__dirname, "..", "src", "view"),
			"service": path.join(__dirname, "..", "src", "service")
		}
	},
	module: {
		rules: [{
			test: /\.(css|less)$/,
			use: ["style-loader", "css-loader", "postcss-loader", "less-loader"]
		}, {
			test: /\.(js|jsx)$/,
			exclude: /node_modules/, //剔除掉需要忽略的资源
			include: path.join(__dirname, "..", "src"),
			use: [{
				loader: "babel-loader"
			}]
		}, {
			test: /\.(png|jpg|svg|gif)$/,
			use: [{
				loader: "url-loader",
				options: {
					limit: 200,
					name: "images/[hash].[name].[ext]?[hash:8]"
				}
			}]
		}, {
			test: /\.(woff|woff2|eot|ttr|otf)/,
			use: [
				"file-loader"
			]
		}, {
			test: /\.(csv|tsv)$/,
			use: [
				"csv-loader"
			]
		}, {
			test: /\.xml$/,
			use: [
				"xml-loader"
			]
		}, {
			test: /\.json$/,
			use: [
				"json-loader"
			]
		}, {
			test: require.reslove("jquery"), //此loader配置对象是npm的jquery
			loader: "expose?$!expose?jQuery" //先把jQuery对象生命成为全局变量“jQuery”，在通过管道进一步又声明为全局变量"$"
		}]
	}
};